/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.unitedats.common.Entity;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

import com.unitedats.HR.Entity.HrEmployee;
import com.unitedats.common.util.SearchRequired;

/**
 *
 * @author Awad
 */
@Entity
@Table(name = "sys_user_login")
@XmlRootElement
@NamedQueries({
              @NamedQuery(name = "SysUserLogin.findAll", query = "SELECT s FROM SysUserLogin s"),
              @NamedQuery(name = "SysUserLogin.findById", query = "SELECT s FROM SysUserLogin s WHERE s.id = :id"),
    })
public class SysUserLogin implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Integer id;
  
    @Column(name = "user_name")
    @SearchRequired
    private String userName;
    
  
    @Column(name = "password")
    @SearchRequired
    private String password;
    
   
    @Column(name = "status")
    private Short status;
    
    @JoinColumn(name = "emp_id", referencedColumnName = "id")
    @OneToOne
    private HrEmployee empId;
    
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "userId")
    private List<SysUserRole> sysUserRoleList;

    public SysUserLogin() {
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Short getStatus() {
        return status;
    }

    public void setStatus(Short status) {
        this.status = status;
    }

    public HrEmployee getEmpId() {
        return empId;
    }

    public void setEmpId(HrEmployee empId) {
        this.empId = empId;
    }

    @XmlTransient
    public List<SysUserRole> getSysUserRoleList() {
        return sysUserRoleList;
    }

    public void setSysUserRoleList(List<SysUserRole> sysUserRoleList) {
        this.sysUserRoleList = sysUserRoleList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof SysUserLogin)) {
            return false;
        }
        SysUserLogin other = (SysUserLogin) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.unitedats.common.Entity.SysUserLogin[ id=" + id + " ]";
    }

}
